package com.smec.remes.module.request;
import android.annotation.SuppressLint;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.blankj.utilcode.util.SizeUtils;
import com.hwangjr.rxbus.annotation.Subscribe;
import com.hwangjr.rxbus.annotation.Tag;
import com.hwangjr.rxbus.thread.EventThread;
import com.smec.moblie.R;
import com.smec.moblie.activity.MainActivity;
import com.smec.moblie.databinding.ActivityRemesRequestBinding;
import com.smec.remes.base.SmecBaseFragment;
import com.smec.remes.bean.AbleMatnr;
import com.smec.remes.bean.MantrCheck;
import com.smec.remes.bean.MantrCheckList;
import com.smec.remes.bean.MantrStatus;
import com.smec.remes.bean.RequestSearch;
import com.smec.remes.bean.SubmitApply;
import com.smec.remes.bean.SubmitApplyChildren;
import com.smec.remes.bean.SubmitDetails;
import com.smec.remes.module.request.adapter.SmecRequestAdapter;
import com.smec.remes.module.search.SmecSearchActivity;
import com.smec.remes.module.submit.SmecSubmitFragment;
import com.smec.remes.module.submit.fragment.SmecUnfinishFragment;
import com.smec.remes.module.user.SmecUserActivity;
import com.smec.remes.smecManager.SmecRetrofit.HttpResult;
import com.smec.remes.util.ChoicDate;
import com.smec.remes.util.CommonUtils;
import com.smec.remes.util.RequestContinueDialog;
import com.smec.remes.util.RequestFailDialog;
import com.zyyoona7.lib.EasyPopup;
import com.zyyoona7.lib.HorizontalGravity;
import com.zyyoona7.lib.VerticalGravity;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import static com.smec.remes.module.request.SmecRequestPresenter.GET_ALL_PRICE_FAIL;
import static com.smec.remes.module.request.SmecRequestPresenter.GET_ALL_PRICE_SUCCESS;

/**
 * Created by Administrator on 2017/11/28.
 */

public class SmecRequestFragment extends SmecBaseFragment<SmecRequestPresenter> {

    private ActivityRemesRequestBinding activityRemesRequestBinding;
    private ArrayList<AbleMatnr> ableMatnrArrayList=new ArrayList<>();
    private SmecRequestAdapter smecRequestAdapter;
    private int mYear,mMonth,mDay;
    private String use="SALE";
    public final static String SUBMIT="SUBMIT";
    public final static String RequestSearch="RequestSearch";
    public final static String UserEdit="UserEdit";
    public final static String CHECK="CHECK";
    public final static String CHECKFAIL="CHECKFAIL";
    public final static String UserEditNew="UserEditNew";
    public final static String DETAILS="DETAILS";
    public final static String DETAILSFAIL="DETAILSFAIL";
    public final static String DraftsTo="DraftsTo";
    public final static String SAVE="SAVE";
    public final static String SearchActivity="SearchActivity";
    public final static String UserActivity="UserActivity";
    public final static String DraftsActivity="DraftsActivity";
    public final static String REDUCE_NULL="REDUCE_NULL";
    public final static String REDUCE="REDUCE";
    private SmecSubmitFragment smecSubmitFragment;
    private RequestContinueDialog requestContinueDialog;
    private RequestFailDialog requestFailDialog;
    private ProgressDialog progressDialog;
    private EasyPopup mCirclePop;
    private String days;
    private boolean check=false;
    private Double all=0.00;
    private String applyOrderNo;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        activityRemesRequestBinding=DataBindingUtil.inflate(inflater,R.layout.activity_remes_request,container,false);
        smecRequestAdapter=new SmecRequestAdapter(getActivity(),mRxBus);
        activityRemesRequestBinding.myRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        activityRemesRequestBinding.myRecyclerView.setAdapter(smecRequestAdapter);
        _HideKeyboard();
        _intent();
        _choiceDate();
        _choiceUse();
        _submit();
        _getFragment();
        return activityRemesRequestBinding.getRoot();
    }

    @Override
    protected SmecRequestPresenter getPersenter() {
        return new SmecRequestPresenter(getContext());
    }

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(REDUCE_NULL)
            }
    )

    public void _reduce(String a){
        all=0.00;
        activityRemesRequestBinding.llTotal.setVisibility(View.GONE);
    }

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(REDUCE)
            }
    )

    public void reduce(ArrayList<AbleMatnr> arrayList){
        all=0.00;
        for (int i=0;i<arrayList.size();i++){
            all+=Double.valueOf(arrayList.get(i).getPriceALL());
        }
        activityRemesRequestBinding.llTotal.setVisibility(View.VISIBLE);
        activityRemesRequestBinding.tvPriceRequest.setText(String.valueOf(all));
    }

    public void _getFragment(){
        ArrayList<String> arrayList=getArguments().getStringArrayList("aaa");
        if(CommonUtils.notEmpty(arrayList)){
            _setEdit();
            activityRemesRequestBinding.edRequestName.setText(arrayList.get(0));
            activityRemesRequestBinding.spinner.setText(arrayList.get(1));
            activityRemesRequestBinding.tvRequestDate.setText(arrayList.get(2));
        }
    }
    /**
     * 提交物料申请
     */
    public void _submit(){
        activityRemesRequestBinding.btnRequestSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                MantrCheck mantrCheck=new MantrCheck();
                ArrayList<MantrCheckList> matnrList=new ArrayList<>();
                if(CommonUtils.notEmpty(smecRequestAdapter.getAbleMatnrArrayList())){
                    ArrayList<AbleMatnr> newableMatnrArrayList=smecRequestAdapter.getAbleMatnrArrayList();
                    for(int i=0;i<newableMatnrArrayList.size();i++){
                        MantrCheckList mantrCheckList=new MantrCheckList();
                        mantrCheckList.setMatnr(newableMatnrArrayList.get(i).getMatnr());
                        matnrList.add(mantrCheckList);
                    }
                }
                mantrCheck.setMatnrList(matnrList);

                if(activityRemesRequestBinding.edRequestName.getText()!=null && !activityRemesRequestBinding.edRequestName.getText().toString().equals("")){
                    mantrCheck.setCustomerName(activityRemesRequestBinding.edRequestName.getText().toString());
                }else {
                    Toast.makeText(getActivity(),"请填写完申请单信息",Toast.LENGTH_SHORT).show();
                    return;
                }
                mantrCheck.setPurpose(use);
                if(activityRemesRequestBinding.tvRequestDate.getText()!=null &&
                        !activityRemesRequestBinding.tvRequestDate.getText().toString().equals("")){
                    mantrCheck.setDate(activityRemesRequestBinding.tvRequestDate.getText().toString());
                }else {
                    Toast.makeText(getActivity(),"请选择需求交货日期",Toast.LENGTH_SHORT).show();
                    return;
                }
                mPresenter.checkMantr(mantrCheck);
            }
        });

        activityRemesRequestBinding.btnRequestDraft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(!TextUtils.isEmpty(activityRemesRequestBinding.edRequestName.getText())||
                        !TextUtils.isEmpty(days)){
                    mPresenter.submitApply(_setSelctean("SAVE"));
                    if(progressDialog == null){
                        progressDialog=new ProgressDialog(getActivity());
                    }
                    progressDialog.setMessage("正在保存.....");
                    progressDialog.show();
                }else {
                    Toast.makeText(getActivity(),"请编辑申请单信息",Toast.LENGTH_SHORT).show();
                    return;
                }
            }
        });
    }

    public SubmitApply _setSelctean(String type){
        SubmitApply submitApply=new SubmitApply();
        submitApply.setType(type);
        submitApply.setPurpose(use);
        if(type.equals("SAVE")) {
            submitApply.setApplyOrderNo(applyOrderNo);
        }
        if(!TextUtils.isEmpty(activityRemesRequestBinding.edRequestName.getText().toString()) ){
            submitApply.setCustomerName(activityRemesRequestBinding.edRequestName.getText().toString());
        }
        if(!TextUtils.isEmpty(activityRemesRequestBinding.tvRequestDate.getText().toString()) ){
            submitApply.setDeliveryDate(activityRemesRequestBinding.tvRequestDate.getText().toString());
        }
        if(!TextUtils.isEmpty(activityRemesRequestBinding.remark.getText().toString()) ){
            submitApply.setRemark(activityRemesRequestBinding.remark.getText().toString());
        }
        ArrayList<SubmitApplyChildren> applyChildrenArrayList=new ArrayList<>();
        if(CommonUtils.notEmpty(smecRequestAdapter.getAbleMatnrArrayList())){
            ArrayList<AbleMatnr> newableMatnrArrayList=smecRequestAdapter.getAbleMatnrArrayList();
            for(int i=0;i<newableMatnrArrayList.size();i++){
                SubmitApplyChildren submitApplyChildren=new SubmitApplyChildren();
                submitApplyChildren.setMatnr(newableMatnrArrayList.get(i).getMatnr().toString());
                submitApplyChildren.setApplyQty(Integer.parseInt(newableMatnrArrayList.get(i).getNum()));
                applyChildrenArrayList.add(submitApplyChildren);
            }
            submitApply.setMatnrList(applyChildrenArrayList);
        }else {
            submitApply.setMatnrList(applyChildrenArrayList);
        }
        return submitApply;
    }

    public void _intent(){
        activityRemesRequestBinding.btnRequestName.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(getContext(), SmecUserActivity.class);
                startActivity(intent);
            }
        });

        activityRemesRequestBinding.ivRequestAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(getContext(), SmecSearchActivity.class);
                startActivity(intent);
                activityRemesRequestBinding.getRoot().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if(CommonUtils.notEmpty(smecRequestAdapter.getAbleMatnrArrayList())){
                            mRxBus.post("RequestMantr",ableMatnrArrayList);
                        }

                    }
                },500);
            }
        });

        activityRemesRequestBinding.llAll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(activityRemesRequestBinding.edRequestName.getText().toString().equals("")){
                    _setSelct();
                    CommonUtils.hideImmManager(activityRemesRequestBinding.edRequestName);
                }else{
                    activityRemesRequestBinding.edRequestName.clearFocus();
                    CommonUtils.hideImmManager(activityRemesRequestBinding.edRequestName);
                }
            }
        });

        activityRemesRequestBinding.edRequestName.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                activityRemesRequestBinding.edRequestName.requestFocus();
            }
        });

        activityRemesRequestBinding.ivNameDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                _setSelct();
            }
        });
    }

    public void _HideKeyboard(){
        activityRemesRequestBinding.getRoot().postDelayed(new Runnable() {
            @Override
            public void run() {
                CommonUtils.hideImmManager(activityRemesRequestBinding.getRoot());
            }
        },100);
    }

    public void _choiceUse(){
        activityRemesRequestBinding.llChoiceUse.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showPopupWindow(activityRemesRequestBinding.llChoiceUse);
            }
        });
    }

    private void showPopupWindow(View view){
        mCirclePop = new EasyPopup(getActivity())
                .setContentView(R.layout.layout_choice_use)
                .setAnimationStyle(R.style.QQPopAnim)
                //是否允许点击PopupWindow之外的地方消失
                .setFocusAndOutsideEnable(true)
                //变暗的透明度(0-1)，0为完全透明
                .setDimValue(0.4f)
                //指定任意 ViewGroup 背景变暗
                .createPopup();
        mCirclePop.showAtAnchorView(view, VerticalGravity.BELOW, HorizontalGravity.LEFT, SizeUtils.dp2px(120), 0);
        LinearLayout smecCompare=mCirclePop.getView(R.id.smec_compare);
        smecCompare.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mCirclePop.dismiss();
                activityRemesRequestBinding.spinner.setText("拟销售");
                use="SALE";
            }
        });
        LinearLayout smecDraft=mCirclePop.getView(R.id.smec_draft);
        smecDraft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mCirclePop.dismiss();
                activityRemesRequestBinding.spinner.setText("拟领用");
                use="RECEIVE";
            }
        });
    }

    public void _choiceDate(){
        Calendar calendar=Calendar.getInstance();
        mYear = calendar.get(Calendar.YEAR);
        mMonth = calendar.get(Calendar.MONTH);
        mDay = calendar.get(Calendar.DAY_OF_MONTH);
        activityRemesRequestBinding.llDate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                DatePickerDialog datePickerDialog=new DatePickerDialog(getContext(), onDateSetListener, mYear, mMonth, mDay);
                _setMin(datePickerDialog);
                datePickerDialog.show();
            }
        });
    }

    @SuppressLint("NewApi")
    private void _setMin(DatePickerDialog datePickerDialog){
        if (android.os.Build.VERSION.SDK_INT>=11) {
            datePickerDialog.getDatePicker().setMinDate(new Date().getTime()+24*60*60*1000);
        }
    }

    private DatePickerDialog.OnDateSetListener onDateSetListener = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            days= ChoicDate.set(year,monthOfYear,dayOfMonth);
            activityRemesRequestBinding.tvRequestDate.setText(days);
        }
    };

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(CHECK)
            }
    )

    public void _checkSuccess(HttpResult<ArrayList<MantrStatus>> arrayListHttpResult){
        if(arrayListHttpResult.getData().get(0).getStatus().equals("TO_CONFIRM")){
            requestContinueDialog=new RequestContinueDialog(getContext(),R.style.project_back);
            TextView textView= (TextView) requestContinueDialog.getCustomView().findViewById(R.id.tv_msg);
            textView.setText(arrayListHttpResult.getData().get(0).getErrMsg());
            Button btnCancel= (Button) requestContinueDialog.getCustomView().findViewById(R.id.btn_cancel);
            btnCancel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    requestContinueDialog.dismiss();
                }
            });
            Button btnSure= (Button) requestContinueDialog.getCustomView().findViewById(R.id.btn_sure);
            btnSure.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    mPresenter.submitApply(_setSelctean("SUBMIT"));
                    requestContinueDialog.dismiss();
                    if(progressDialog == null){
                        progressDialog=new ProgressDialog(getActivity());
                    }
                    progressDialog.setMessage("正在提交.....");
                    check=true;
                    progressDialog.show();
                }
            });
            requestContinueDialog.show();
        }else if(arrayListHttpResult.getData().get(0).getStatus().equals("FAILED")){
            requestFailDialog=new RequestFailDialog(getContext(),R.style.project_back);
            TextView textView= (TextView) requestFailDialog.getCustomView().findViewById(R.id.tv_msg);
            textView.setText(arrayListHttpResult.getData().get(0).getErrMsg());
            Button btnCancel= (Button) requestFailDialog.getCustomView().findViewById(R.id.btn_sure);
            btnCancel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    requestFailDialog.dismiss();
                }
            });
            requestFailDialog.show();
        }else {
            mPresenter.submitApply(_setSelctean("SUBMIT"));
            if(progressDialog == null){
                progressDialog=new ProgressDialog(getActivity());
            }
            progressDialog.setMessage("正在提交.....");
            check=true;
            progressDialog.show();
        }

    }

    @Override
    public void onResume() {
        super.onResume();
        if(!CommonUtils.notEmpty(smecRequestAdapter.getAbleMatnrArrayList())){
            activityRemesRequestBinding.llTotal.setVisibility(View.GONE);
        }
    }

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(SUBMIT)
            }
    )

    public void searchUser(String s){
        progressDialog.dismiss();
        Toast.makeText(getContext(),"提交成功",Toast.LENGTH_SHORT).show();
        activityRemesRequestBinding.edRequestName.setText("");
        activityRemesRequestBinding.tvRequestDate.setText("");
        days="";
        _setSelct();
        smecRequestAdapter._clearList();
        activityRemesRequestBinding.getRoot().postDelayed(new Runnable() {
            @Override
            public void run() {
                ((MainActivity)getActivity()).textView_title.setText("已提交申请");
                if(smecSubmitFragment == null){
                    smecSubmitFragment=SmecSubmitFragment.newInstance();
                }
                ((MainActivity)getActivity()).switchContent(((MainActivity)getActivity()).mContent,smecSubmitFragment);
                activityRemesRequestBinding.getRoot().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mRxBus.post(SmecUnfinishFragment.UNFINISHREFRESH,"");
                    }
                },500);
                activityRemesRequestBinding.llTotal.setVisibility(View.GONE);

            }
        },700);
        applyOrderNo = null;
        activityRemesRequestBinding.remark.setText("");
    }

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(SAVE)
            }
    )

    public void searchSAVE(String s){
        Toast.makeText(getContext(),"保存成功",Toast.LENGTH_SHORT).show();
        activityRemesRequestBinding.getRoot().postDelayed(new Runnable() {
            @Override
            public void run() {
                progressDialog.dismiss();
                activityRemesRequestBinding.edRequestName.setText("");
                activityRemesRequestBinding.tvRequestDate.setText("");
                days="";
                _setSelct();
                smecRequestAdapter.getAbleMatnrArrayList().clear();
                activityRemesRequestBinding.llTotal.setVisibility(View.GONE);
                smecRequestAdapter.notifyDataSetChanged();
                activityRemesRequestBinding.invalidateAll();
            }
        },700);
        applyOrderNo = null;
        activityRemesRequestBinding.remark.setText("");
    }

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(SearchActivity)
            }
    )
    public void SearchActivity( ArrayList<AbleMatnr> arrayList){
        if(CommonUtils.notEmpty(arrayList)){
            smecRequestAdapter._clearList();
            all=0.00;
            ableMatnrArrayList=arrayList;
            smecRequestAdapter.setArrayList(ableMatnrArrayList);
            for (int i=0;i<arrayList.size();i++){
                all+=Double.valueOf(arrayList.get(i).getPriceALL());
            }
            activityRemesRequestBinding.llTotal.setVisibility(View.VISIBLE);
            activityRemesRequestBinding.tvPriceRequest.setText(String.valueOf(all));
        }else {
            smecRequestAdapter._clearList();
            all=0.00;
            activityRemesRequestBinding.llTotal.setVisibility(View.GONE);
        }
    }

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(UserActivity)
            }
    )
    public void UserActivity(String name){
        if(!TextUtils.isEmpty(name)){
            _setEdit();
            activityRemesRequestBinding.edRequestName.setText(name);
        }
    }

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(UserEdit)
            }
    )

    public void _UserEdit(String name){
        _setEdit();
        activityRemesRequestBinding.edRequestName.setText("");
        activityRemesRequestBinding.edRequestName.postDelayed(new Runnable() {
            @Override
            public void run() {
                activityRemesRequestBinding.edRequestName.setFocusable(true);
                activityRemesRequestBinding.edRequestName.setFocusableInTouchMode(true);
                activityRemesRequestBinding.edRequestName.requestFocus();
                activityRemesRequestBinding.edRequestName.requestFocusFromTouch();
                CommonUtils.showImmManager(activityRemesRequestBinding.edRequestName);
            }
        },500);
    }

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(DraftsTo)
            }
    )
    public void _DraftsTo(ArrayList<String> arrayList){
        Log.w("DraftsA", String.valueOf(arrayList.size()));
    }

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(RequestSearch)
            }
    )
    public void _RequestSearch(RequestSearch requestSearch){
        activityRemesRequestBinding.edRequestName.setText(requestSearch.getCustomerName());
        activityRemesRequestBinding.spinner.setText(requestSearch.getPurposeName());
        activityRemesRequestBinding.tvRequestDate.setText(requestSearch.getDeliveryDate());
        applyOrderNo = requestSearch.getApplyOrderNo();
        mPresenter._submitDetails(requestSearch.getApplyOrderNo());
        _setEdit();
        activityRemesRequestBinding.userRemark.setVisibility(View.VISIBLE);
    }

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(DETAILS)
            }
    )
    public void _Details(ArrayList<SubmitDetails> arrayList){
        if(CommonUtils.notEmpty(arrayList)){
            ArrayList<AbleMatnr> ableMatnrArrayList=new ArrayList<>();
           if(CommonUtils.notEmpty(arrayList.get(0).getMatnrList())){
               for(int i=0;i<arrayList.get(0).getMatnrList().size();i++){
                   AbleMatnr ableMatnr=new AbleMatnr();
                   ableMatnr.setMatnr(arrayList.get(0).getMatnrList().get(i).getMatnr());
                   ableMatnr.setMatnrName(arrayList.get(0).getMatnrList().get(i).getMatnrName());
                   ableMatnr.setMatnrBranchQty(arrayList.get(0).getMatnrList().get(i).getMatnrBranchQty());
                   ableMatnr.setMatnrHdQty(arrayList.get(0).getMatnrList().get(i).getMatnrHdQty());
                   ableMatnr.setImageLink(arrayList.get(0).getMatnrList().get(i).getImageLink());
                   ableMatnr.setNum(arrayList.get(0).getMatnrList().get(i).getApplyQty());
                   ableMatnr.setChangeMessage(arrayList.get(0).getMatnrList().get(i).getChangeMessage());
                   ableMatnr.setPkgUnit(arrayList.get(0).getMatnrList().get(i).getPkgUnit());
                   ableMatnrArrayList.add(ableMatnr);
                   String num=arrayList.get(0).getMatnrList().get(i).getApplyQty();
               }
               smecRequestAdapter.setArrayList(ableMatnrArrayList);
               if(progressDialog == null){
                   progressDialog=new ProgressDialog(getContext());
                   progressDialog.setMessage("正在获取价格信息");
               }
               progressDialog.show();
               mPresenter.getAllPrice(ableMatnrArrayList);
           }
        }
    }

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(GET_ALL_PRICE_SUCCESS)
            }
    )
    public void getPriceSuccess(SmecMatnrMsg smecMatnrMsg){

        int allPrice=0;
        if(CommonUtils.notEmpty(smecMatnrMsg.getMatnrList())){
            smecRequestAdapter.setArrayList(smecMatnrMsg.getMatnrList());
            activityRemesRequestBinding.llTotal.setVisibility(View.VISIBLE);
            activityRemesRequestBinding.tvPriceRequest.setText(String.valueOf(smecMatnrMsg.getMatnrAll()));
        }
        if(progressDialog !=null && progressDialog.isShowing()){
            progressDialog.dismiss();
        }
    }

    @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = {
                    @Tag(GET_ALL_PRICE_FAIL)
            }
    )
    public void getPriceFail(Object o){

        if(progressDialog !=null && progressDialog.isShowing()){
            progressDialog.dismiss();
        }
    }

    public void _setEdit(){
        activityRemesRequestBinding.btnRequestName.setVisibility(View.GONE);
        activityRemesRequestBinding.edRequestName.setVisibility(View.VISIBLE);
        activityRemesRequestBinding.ivNameDelete.setVisibility(View.VISIBLE);
    }

    public void _setSelct(){
        activityRemesRequestBinding.btnRequestName.setVisibility(View.VISIBLE);
        activityRemesRequestBinding.edRequestName.setVisibility(View.GONE);
        activityRemesRequestBinding.ivNameDelete.setVisibility(View.GONE);
        activityRemesRequestBinding.edRequestName.setText("");
    }

    public static SmecRequestFragment newInstance() {
        Bundle args = new Bundle();
        SmecRequestFragment fragment = new SmecRequestFragment();
        fragment.setArguments(args);
        return fragment;
    }
}
